#include<stdio.h>

#define N 10
#define M 11

void insert_num(int arr[], int n, int num, int arr1[], int m);
int main(int argc, char *argv[]){
	int num;
	int arr[N] = {1, 3, 5, 7, 15, 17, 21, 23, 30, 51};
	int arr1[M] = {0};
	for(int i = 0; i < N; i++){
		printf("%d ", arr[i]);
	}
	printf("\n");
	printf("请输入要插入的数字：");
	scanf("%d", &num);
	insert_num(arr, N, num, arr1, M);
	printf("\n");

	for(int i = 0; i < M; i++){
		printf("%d ", arr1[i]);
	}
	printf("\n");

	return 0;
}
int find_index(int arr[],int n, int num){
	int index = n;
	for(int i = 0; i < n; i++){
		if(arr[i] > num){
			index = i;
			break;
		}
	}	
	return index;
}
void insert_num(int arr[], int n, int num, int arr1[], int m){
	int i;
	int index;
	index = find_index(arr, n, num);
	
	for(i = 0; i < n; i++){
		arr1[i] = arr[i];
	}

	for(i = m-1; i > index; i--){
		arr1[i] = arr1[i-1];
	}
		arr1[index] = num;
	return;
}


